#include <stdio.h>
#include <string.h>

#define NMAX 100002
#define STACK_DATA_TYPE char

const char *opening_br = "([{<";
const char *closing_br = ")]}>";

/* {{{ CTAKAH */
#ifndef STACK_H
#define STACK_H

#ifndef NMAX
const int NMAX = 500000;
#endif /* #ifndef NMAX */

#ifndef STACK_DATA_TYPE
#define STACK_DATA_TYPE int
#endif /* #ifndef STACK_DATA_TYPE */
struct Stack {
	STACK_DATA_TYPE data[NMAX];
	int size;
};
#endif /* #ifndef STACK_H */


extern void
Clear(struct Stack * s)
{
	s->size = 0;
}



extern void
Push(struct Stack * s, STACK_DATA_TYPE new_)
{
	s->data[s->size] = new_;
	++(s->size);
}



extern STACK_DATA_TYPE
Pop(struct Stack * s)
{
	if (s->size)
		--s->size;
	return s->data[s->size];
}



extern STACK_DATA_TYPE
Top(const struct Stack * s)
{
	return s->data[s->size - 1];
}



extern unsigned char
IsEmpty(const struct Stack * s)
{
	return s->size ? 0 : 1;
}
/* }}} */


int
main(void)
{
	struct Stack CTAKAH;
	char br;
	char *msg_no  = "NO";
	char *msg_yes = "YES";

	(void) freopen("brackets.in", "r", stdin);
	(void) freopen("brackets.out", "w", stdout);

	CTAKAH.size = 0;

	while (br = getchar(), br != EOF && br != '\n') {
		if (strchr(opening_br, br)) {
			Push(&CTAKAH, br);
		} else if (Top(&CTAKAH) != opening_br[strchr(closing_br, br) - closing_br] || IsEmpty((const Stack*)&CTAKAH)) {
			printf("%s\n", msg_no);
			return 0;
		} else {
			Pop(&CTAKAH);
		}
	}
	if (IsEmpty((const Stack*)&CTAKAH))
		printf("%s\n", msg_yes);
	else
		printf("%s\n", msg_no);
	return 0;
}
// vim: foldmethod=marker :
